<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <title></title>
    <style media="screen">
    body {height:2000px;}
    .box {width:200px; height:200px; background:#CCC; border:1px solid black; position:absolute; line-height:200px; text-align:center; font-size:40px; left:50%; top:150px; margin-left:-100px; transform:scale(1);}
    </style>
    <script>
    function calcDistance(touch1, touch2){
      return Math.sqrt(Math.pow(touch1.clientX-touch2.clientX, 2), Math.pow(touch1.clientY-touch2.clientY, 2));
    }
    window.onload=function (){
      let oBox=document.getElementsByClassName('box')[0];

      let dis1,dis2;
      let scale=1.0,old_scale;

      document.addEventListener('touchstart', function (ev){
        if(ev.targetTouches.length>=2){
          dis1=calcDistance(ev.targetTouches[0], ev.targetTouches[1]);

          old_scale=scale;
        }
      }, false);

      document.addEventListener('touchmove', function (ev){
        if(ev.targetTouches.length>=2){
          dis2=calcDistance(ev.targetTouches[0], ev.targetTouches[1]);

          scale=old_scale*dis2/dis1;

          oBox.style.transform=`scale(${scale})`;
        }
      }, false);
    };
    </script>
  </head>
  <body>
    <div class="box">asdfasdf</div>
  </body>
</html>
